<?php
class DataGuest{
	private $Identify = array();
	private $SecretKey = array();
	function __construct($identify){
		$this->Identify = unpack('C*', $identify ) ;
		$this->SecretKey = UtilHash::generateKey( 32 ) ;
	}
	static function swap($bytebuffer){
		$obj = new DataGuest(implode(array_map("chr",  DataUtil::readBBin( $bytebuffer )  )) );
		$obj->SecretKey = DataUtil::readBBin( $bytebuffer ) ;
		return $obj;
	}
	function getIdentify(){
		return $this->Identify;
	}
	function getSecretKey(){
		return $this->SecretKey;
	}
	function getBinSize(){
		$size = 0;
		$size += 1 ;
		if(is_array($this->Identify))$size += count($this->Identify);
		$size += 1 ;
		if(is_array($this->SecretKey))$size += count($this->SecretKey);
		return $size;
	}
	function getBinary(){
		$buf = ByteBuffer::allocate( $this->getBinSize() ) ;
		DataUtil::writeBBin( $buf , $this->Identify ) ;
		DataUtil::writeBBin( $buf , $this->SecretKey ) ;
		return  $buf ->_array() ;
	}
}
?>